<template>
  <div class="collect-page">
    <div id="box">
      <div @click="$router.back()" id="left">
        <van-icon color="#fff" size="22" name="arrow-left" />
      </div>
      <input type="text" placeholder="请输入小区或地址" />
      <div @click="$router.push('/mapMap')" id="right">
        <van-icon color="#fff" size="26" name="location-o" />
      </div>
    </div>
    <van-dropdown-menu>
      <van-dropdown-item v-model="value" :options="option1" />
      <van-dropdown-item v-model="value1" :options="option2" />
      <van-dropdown-item v-model="value2" :options="option3" />
      <van-dropdown-item title="筛选" ref="item">
        <van-cell center title="包邮">
          <template #right-icon>
            <van-switch v-model="switch1" size="24" active-color="#ee0a24" />
          </template>
        </van-cell>

        <van-cell center title="团购">
          <template #right-icon>
            <van-switch v-model="switch2" size="24" active-color="#ee0a24" />
          </template>
        </van-cell>

        <div style="padding: 5px 16px">
          <van-button type="danger" block round @click="onConfirm">
            确认
          </van-button>
        </div>
      </van-dropdown-item>
    </van-dropdown-menu>
    <!-- 列表 -->
    <div class="article-page">
      <div class="article-item" v-for="item in info" :key="item.id">
        <div class="left">
          <img
            :src="`http://liufusong.top:8080` + item.houseImg"
            alt="图片加载失败"
          />
        </div>
        <div class="body" @click="tto(item.houseCode)">
          <!-- http://liufusong.top:8080/uploads/upload_907fabc90faabd08a4a33a4fc766946c.ico -->
          <h2>{{ item.price }}</h2>
          <p class="p1">{{ item.desc }}</p>
          <span>{{ item.tags[0] }}</span>
          <p class="p2">{{ item.price }}</p>
          <p class="p3">元/月</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import axios from 'axios'
import { find } from '@/api/user'
export default {
  name: 'collect-page',
  data () {
    return {
      info: null,
      value: 0,
      value1: 'a',
      value2: 'b',

      switch1: false,
      switch2: false,
      option1: [
        { text: '区域', value: 0 },
        { text: '地铁', value: 1 }
      ],
      option2: [
        { text: '方式', value: 'a' },
        { text: '整租', value: 1 },
        { text: '合租', value: 2 }
      ],
      option3: [
        { text: '租金', value: 'b' },
        { text: '新款商品', value: 1 },
        { text: '活动商品', value: 2 }
      ]
    }
  },
  async created () {
    const data = await find()
    console.log(data)
    this.info = data.body.list
  },
  methods: {
    // add (id) {
    //   this.$router.push({
    // path: '/collectone'
    //   })
    // },
    tto (id) {
      // console.log(id)
      console.log(id)
      this.$router.push({
        path: '/desc',
        query: {
          id
        }
      })
    },
    onSearch (val) {},
    onCancel (val) {},
    onConfirm () {
      this.$refs.item.toggle()
    }
  }
}
</script>

<style lang="less" scoped>
#box {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  width: 100%;
  height: 50px;
  background-color: #21b97a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
input {
  width: 274px;
  height: 34px;
  border-radius: 3px;
  background: #fff;
  outline: none;
  border: 0px;
  font-size: 13px;
  color: #9c9fa3;
  padding-left: 10px;
}

#left {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #21b97a;
  font-size: 12px;
  width: 30px;
  height: 30px;
  margin-left: 10px;
}
#right {
  align-items: center;
  justify-content: center;
  display: flex;
  color: #21b97a;
  font-size: 12px;
  width: 30px;
  height: 30px;
  margin-right: 10px;
}
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
.article-item {
  display: flex;
  align-content: space-between;
  border-bottom: 1px solid #ccc;
}
.left {
  // border: 2px solid red;
  width: 120px;
  height: 120px;
  img {
    width: 100%;
    height: 100%;
  }
}
.body {
  position: relative;
  // border: 2px solid red;
  height: 100px;
  width: 250px;
  h2 {
    font-size: 15px;
    position: absolute;
    left: 5px;
    top: 0px;
  }
  span {
    display: inline-block;
    background-color: #e1f5f8;
    color: #39becd;
    width: 50px;
    height: 20px;
    line-height: 20px;
    font-size: 12px;
    position: absolute;
    left: 5px;
    top: 55px;
  }
}
.p1 {
  font-size: 12px;
  color: #afb2b3;
  position: absolute;
  left: 5px;
  top: 20px;
}
.p2 {
  position: absolute;
  left: 5px;
  top: 62px;
  color: #fa5741;
  font-size: 16px;
  font-weight: 700;
}
.p3 {
  position: absolute;
  left: 40px;
  top: 66px;
  color: #fa5741;
  font-size: 12px;
}
.pl1 {
  width: 100%;
  display: inline-block;
  top: 0;
  position: fixed;
  z-index: 999;
}
</style>
